#pragma once
#include <iostream>
template <class T>
class Task
{
    const static std::string opers;

public:
    Task(T data1, T data2, char op)
        : _data1(data1), _data2(data2), _op(op), _result(T()),_exitcode(0)
    {}
    const static std::string GetOpers()
    {
        return opers;
    }
    void Run()
    {
        switch (_op)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '/':
            if (_data2 == T())
                _exitcode=1;
            else
                _result = _data1 / _data2;
            break;
        case '%':
            if (_data2 == T())
                _exitcode=1;
            else
                _result = _data1 % _data2;
            break;
        }
    }
    void operator()()
    {
        Run();
    }
    std::string GetTask()
    {
        std::string r=std::to_string(_data1);
        r+=_op;
        r+=std::to_string(_data2);
        r+="=?";
        return r;
    }
    std::string GetResult()
    {
        std::string r=std::to_string(_data1);
        r+=_op;
        r+=std::to_string(_data2);
        r+="=";
        r+=std::to_string(_result);
        r+="[code: ";
        r+=std::to_string(_exitcode);
        r+="]";
        return r;
    }
    ~Task() {};

private:
    T _data1;
    T _data2;
    T _result;
    int _exitcode;
    char _op;
};
template <class T>
const std::string Task<T>::opers = "+-*/%";